<%@page pageEncoding="UTF-8" isELIgnored="false" session="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@taglib prefix="f" uri="http://www.slim3.org/functions"%>
<!doctype html>
<html>
<head>
<meta charset=UTF-8>
<script type="text/javascript" src="/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src='/_ah/channel/jsapi'></script>
<script type="text/javascript">

	var isConnected = false;

	$(function() {
		var channel = new goog.appengine.Channel("${ token }");
		var socket = channel.open();
		socket.onopen = function() {
			isConnected = true;
		};
		socket.onmessage = function(message) {
			$("#message").val(message.data);
		};
		socket.onerror = function(e) {
			alert("error");
			console.log(e);
		};
		socket.onclose = function() {
			isConnected = false;
		};
	});
</script>
</head>
<body>
	<input type="text" id="userId" value="${ userId }" size="100" />
	<input type="text" id="message" />
</body>
</html>
